/*
 * SeamGenBrFrame.java
 *
 * Created on 28/07/2010, 15:23:17
 */
package br.gen.seam.gui;

import br.gen.seam.exception.SeamGenBrException;
import br.gen.seam.generator.Configuration;
import br.gen.seam.generator.Generator;
import br.gen.seam.generator.SeamGenerator;
import br.gen.seam.generator.exception.GeneratorException;
import br.gen.seam.readerInfoDatabase.ReaderInfoDatabaseFactory;
import br.gen.seam.util.entity.Schema;
import br.gen.seam.util.entity.Table;
import br.gen.seam.util.readerInfoDatabase.ReaderInfoDatabase;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;

/**
 *
 * @author Diego Araujo | diegogomesaraujo@gmail.com
 * @version 1.0
 */
public class SeamGenBrFrame extends javax.swing.JFrame {

    /** Creates new form SeamGenBrFrame */
    public SeamGenBrFrame() throws SeamGenBrException {
        initComponents();
        tabPanel.setEnabledAt(1, false);
        tabPanel.setEnabledAt(2, false);
        comboBoxTypeDatabases.addItem("");
        comboBoxTypeDatabases.addItem(new ValueComboBox("SQL Server", "br.gen.seam.sqlserver.SqlServer"));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tabPanel = new javax.swing.JTabbedPane();
        panelDataConnection = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        fieldPassword = new javax.swing.JPasswordField();
        fieldDatabaseName = new javax.swing.JTextField();
        fieldUser = new javax.swing.JTextField();
        fieldUrlConnection = new javax.swing.JTextField();
        comboBoxTypeDatabases = new javax.swing.JComboBox();
        buttonNext = new javax.swing.JButton();
        panelFeaturesProject = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        fieldPacoteDao = new javax.swing.JTextField();
        fieldPacoteEntity = new javax.swing.JTextField();
        fieldPacoteBean = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        fieldPathProject = new javax.swing.JTextField();
        buttonSelectPathProject = new javax.swing.JButton();
        panelSelectTables = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        listTables = new javax.swing.JTable();
        buttonGenerate1 = new javax.swing.JButton();
        jLabel13 = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        menuSeamGenBr = new javax.swing.JMenu();
        menuItemNew = new javax.swing.JMenuItem();
        menuItemExit = new javax.swing.JMenuItem();
        menuHelp = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Seam Gen Br Generator");
        setResizable(false);

        jLabel1.setText("Type Database:");

        jLabel2.setText("Database:");

        jLabel3.setText("User:");

        jLabel4.setText("Password:");

        jLabel5.setText("URL Connection:");

        buttonNext.setText("Next");
        buttonNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextFrameFreatures(evt);
            }
        });

        javax.swing.GroupLayout panelDataConnectionLayout = new javax.swing.GroupLayout(panelDataConnection);
        panelDataConnection.setLayout(panelDataConnectionLayout);
        panelDataConnectionLayout.setHorizontalGroup(
            panelDataConnectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDataConnectionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDataConnectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(buttonNext, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(panelDataConnectionLayout.createSequentialGroup()
                        .addGroup(panelDataConnectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1))
                        .addGap(37, 37, 37)
                        .addGroup(panelDataConnectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(comboBoxTypeDatabases, 0, 377, Short.MAX_VALUE)
                            .addComponent(fieldDatabaseName, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
                            .addComponent(fieldPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(fieldUser, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
                            .addComponent(fieldUrlConnection, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE))))
                .addContainerGap())
        );
        panelDataConnectionLayout.setVerticalGroup(
            panelDataConnectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDataConnectionLayout.createSequentialGroup()
                .addGap(13, 13, 13)
                .addGroup(panelDataConnectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(comboBoxTypeDatabases, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelDataConnectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(fieldDatabaseName))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelDataConnectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(fieldUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelDataConnectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(fieldPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(panelDataConnectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(fieldUrlConnection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addGap(18, 18, 18)
                .addComponent(buttonNext)
                .addGap(24, 24, 24))
        );

        tabPanel.addTab("Data Connection", panelDataConnection);

        jButton1.setText("Next");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextTabSelectTables(evt);
            }
        });

        jLabel6.setForeground(new java.awt.Color(255, 0, 0));
        jLabel6.setText("Exemple:");

        jLabel7.setText("Dao's");

        jLabel8.setText("Entity's");

        jLabel9.setText("Bean's");

        jLabel11.setForeground(new java.awt.Color(255, 0, 0));
        jLabel11.setText("br.gen.seam.${schema}.${table}");

        jLabel10.setForeground(new java.awt.Color(255, 0, 0));
        jLabel10.setText("Set the naming of the packages to be generated");

        jLabel12.setText("Path");

        buttonSelectPathProject.setText("Select Path Project");
        buttonSelectPathProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                selectPathProject(evt);
            }
        });

        javax.swing.GroupLayout panelFeaturesProjectLayout = new javax.swing.GroupLayout(panelFeaturesProject);
        panelFeaturesProject.setLayout(panelFeaturesProjectLayout);
        panelFeaturesProjectLayout.setHorizontalGroup(
            panelFeaturesProjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelFeaturesProjectLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelFeaturesProjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelFeaturesProjectLayout.createSequentialGroup()
                        .addGap(77, 77, 77)
                        .addComponent(jLabel11))
                    .addComponent(jLabel10)
                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(panelFeaturesProjectLayout.createSequentialGroup()
                        .addGroup(panelFeaturesProjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addComponent(jLabel6)
                            .addComponent(jLabel9)
                            .addComponent(jLabel8)
                            .addComponent(jLabel12))
                        .addGap(18, 18, 18)
                        .addGroup(panelFeaturesProjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(fieldPacoteBean, javax.swing.GroupLayout.DEFAULT_SIZE, 442, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelFeaturesProjectLayout.createSequentialGroup()
                                .addComponent(fieldPathProject, javax.swing.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(buttonSelectPathProject))
                            .addComponent(fieldPacoteEntity, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 442, Short.MAX_VALUE)
                            .addComponent(fieldPacoteDao, javax.swing.GroupLayout.DEFAULT_SIZE, 442, Short.MAX_VALUE))))
                .addContainerGap())
        );
        panelFeaturesProjectLayout.setVerticalGroup(
            panelFeaturesProjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelFeaturesProjectLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelFeaturesProjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(panelFeaturesProjectLayout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(18, 18, 18)
                        .addGroup(panelFeaturesProjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(fieldPacoteDao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelFeaturesProjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(fieldPacoteEntity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelFeaturesProjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(fieldPacoteBean, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelFeaturesProjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelFeaturesProjectLayout.createSequentialGroup()
                        .addGap(45, 45, 45)
                        .addComponent(jButton1))
                    .addGroup(panelFeaturesProjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(fieldPathProject, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel12)
                        .addComponent(buttonSelectPathProject)))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        tabPanel.addTab("Features Project", panelFeaturesProject);

        listTables.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(listTables);

        buttonGenerate1.setText("Generate");
        buttonGenerate1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                generateProjectAction(evt);
            }
        });

        jLabel13.setForeground(new java.awt.Color(255, 0, 0));
        jLabel13.setText("Select tables for generation");

        javax.swing.GroupLayout panelSelectTablesLayout = new javax.swing.GroupLayout(panelSelectTables);
        panelSelectTables.setLayout(panelSelectTablesLayout);
        panelSelectTablesLayout.setHorizontalGroup(
            panelSelectTablesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSelectTablesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelSelectTablesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 519, Short.MAX_VALUE)
                    .addComponent(jLabel13)
                    .addComponent(buttonGenerate1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        panelSelectTablesLayout.setVerticalGroup(
            panelSelectTablesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSelectTablesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel13)
                .addGap(13, 13, 13)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(buttonGenerate1)
                .addContainerGap(17, Short.MAX_VALUE))
        );

        tabPanel.addTab("Select Tables", panelSelectTables);

        menuSeamGenBr.setText("Seam Gen Br");

        menuItemNew.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        menuItemNew.setMnemonic('N');
        menuItemNew.setText("New");
        menuSeamGenBr.add(menuItemNew);

        menuItemExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        menuItemExit.setMnemonic('S');
        menuItemExit.setText("Exit");
        menuItemExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeAplication(evt);
            }
        });
        menuSeamGenBr.add(menuItemExit);

        menuBar.add(menuSeamGenBr);

        menuHelp.setText("Help");
        menuBar.add(menuHelp);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tabPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(tabPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void closeAplication(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeAplication
        System.exit(0);
    }//GEN-LAST:event_closeAplication

    private void generateProjectAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generateProjectAction
        List<Table> tables = new ArrayList<Table>();
        for (int i = 0; i < listTables.getRowCount(); i++) {
            if (!(Boolean) listTables.getValueAt(i, 0)) {
                continue;
            }
            for (Schema schema : schemas) {
                Schema schemaObj = (Schema) listTables.getValueAt(i, 1);
                if (schema != null && !schema.getName().equals(schemaObj.getName())) {
                    continue;
                } else {
                    for (Table table : schema.getTables()) {
                        Table tableObj = (Table) listTables.getValueAt(i, 2);
                        if (table.getName().equals(tableObj.getName())) {
                            tables.add(table);
                        }
                    }
                }
            }
        }

        Generator gen = new SeamGenerator();
        gen.init(tables);
        try {
            gen.generatePackages();
            gen.generateEntities();
            gen.generateBeans();
        } catch (GeneratorException ex) {
            ex.printStackTrace();
        }
    }//GEN-LAST:event_generateProjectAction

    private void nextFrameFreatures(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextFrameFreatures
        int indexSelected = comboBoxTypeDatabases.getSelectedIndex();
        if (indexSelected <= 0) {
            errorMessage("Select the type of database!");
            return;
        }
        if (fieldDatabaseName.getText().trim().length() == 0) {
            errorMessage("Report the name of database!");
            return;
        }
        if (fieldUser.getText().trim().length() == 0) {
            errorMessage("Report the user of database!");
            return;
        }
        if (fieldUrlConnection.getText().trim().length() == 0) {
            errorMessage("Report the url connection of database!");
            return;
        }
        tabPanel.setEnabledAt(1, true);
        tabPanel.setSelectedIndex(1);
    }//GEN-LAST:event_nextFrameFreatures

    private void selectPathProject(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectPathProject
        final JFileChooser fileChooser = new JFileChooser();
        fileChooser.setMultiSelectionEnabled(false);
        fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        fileChooser.addChoosableFileFilter(new FileFilter() {

            @Override
            public boolean accept(File file) {
                if (file.isDirectory()) {
                    return true;
                } else {
                    return false;
                }
            }

            @Override
            public String getDescription() {
                return "";
            }
        });
        fileChooser.showOpenDialog(null);
        File file = fileChooser.getSelectedFile();
        fieldPathProject.setText(file.getAbsolutePath());
    }//GEN-LAST:event_selectPathProject

    private void nextTabSelectTables(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextTabSelectTables
        if (fieldPathProject.getText().trim().length() == 0) {
            errorMessage("Report the path for your project!");
            return;
        }

        SelectTablesModel selectTablesModel = new SelectTablesModel();
        selectTablesModel.setTables(null);

        ValueComboBox valueComboBox = (ValueComboBox) comboBoxTypeDatabases.getSelectedItem();
        try {
            ReaderInfoDatabase readerInfoDatabase = ReaderInfoDatabaseFactory.factoryReaderDatabase(valueComboBox.getClazz());
            readerInfoDatabase.setDataConnection(fieldUrlConnection.getText(),
                    fieldDatabaseName.getText(),
                    fieldUser.getText(),
                    String.valueOf(fieldPassword.getPassword()));
            schemas = readerInfoDatabase.listAllSchemas();

            for (Schema schema : schemas) {
                selectTablesModel.setTables(schema.getTables());
            }

        } catch (SeamGenBrException ex) {
            errorMessage(ex.getMessage());
            ex.printStackTrace();
            return;
        }

        listTables.setModel(selectTablesModel);

        Configuration configuration = Configuration.getCurrentInstance();
        configuration.setPackageDao(fieldPacoteDao.getText());
        configuration.setPackageEntity(fieldPacoteEntity.getText());
        configuration.setPackageBean(fieldPacoteBean.getText());
        configuration.setPathProject(fieldPathProject.getText());

        tabPanel.setEnabledAt(2, true);
        tabPanel.setSelectedIndex(2);
    }//GEN-LAST:event_nextTabSelectTables

    private void errorMessage(String msg) {
        JOptionPane.showMessageDialog(null, msg,
                "Error", JOptionPane.ERROR_MESSAGE);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonGenerate1;
    private javax.swing.JButton buttonNext;
    private javax.swing.JButton buttonSelectPathProject;
    private javax.swing.JComboBox comboBoxTypeDatabases;
    private javax.swing.JTextField fieldDatabaseName;
    private javax.swing.JTextField fieldPacoteBean;
    private javax.swing.JTextField fieldPacoteDao;
    private javax.swing.JTextField fieldPacoteEntity;
    private javax.swing.JPasswordField fieldPassword;
    private javax.swing.JTextField fieldPathProject;
    private javax.swing.JTextField fieldUrlConnection;
    private javax.swing.JTextField fieldUser;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable listTables;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenu menuHelp;
    private javax.swing.JMenuItem menuItemExit;
    private javax.swing.JMenuItem menuItemNew;
    private javax.swing.JMenu menuSeamGenBr;
    private javax.swing.JPanel panelDataConnection;
    private javax.swing.JPanel panelFeaturesProject;
    private javax.swing.JPanel panelSelectTables;
    private javax.swing.JTabbedPane tabPanel;
    // End of variables declaration//GEN-END:variables
    private List<Schema> schemas;
}

final class ValueComboBox {

    private String description;
    private String clazz;

    public ValueComboBox(String description, String clazz) {
        this.description = description;
        this.clazz = clazz;
    }

    public String getDescription() {
        return description;
    }

    public Class getClazz() throws SeamGenBrException {
        try {
            return Class.forName(clazz);
        } catch (ClassNotFoundException ex) {
            throw new SeamGenBrException("Error when load class (" + clazz + "): " + ex.getMessage(), ex);
        }
    }

    @Override
    public String toString() {
        return description;
    }
}
